package cn.regexp.common.redis.enums;

import lombok.Getter;

import java.util.concurrent.TimeUnit;

/**
 * @author Regexpei
 * @date 2024/7/3 21:28
 * @description Redis key 枚举
 */
@Getter
public enum CommonRedisKeyEnum {

    USER_TOKEN("userToken:", TimeUnit.MINUTES, 30);

    /**
     * key 前缀
     */
    private final String prefix;
    /**
     * 有效时间
     */
    private final int expireTime;
    /**
     * 有效时间单位
     */
    private final TimeUnit unit;

    CommonRedisKeyEnum(String prefix, TimeUnit unit, int expireTime) {
        this.prefix = prefix;
        this.unit = unit;
        this.expireTime = expireTime;
    }

    public String getRealKey(String key) {
        return this.prefix + key;
    }

}
